﻿using System.Collections.Generic;

namespace TopHero
{
    public class Path
    {
        private List<Vector2> _wayPoints;
        private int _current;
        private bool _isLoop;

        public Path(List<Vector2> wayPoints, bool isLoop)
        {
            _wayPoints = wayPoints;
            _isLoop = isLoop;
            _current = 0;
        }

        public List<Vector2> GetWayPoints()
        {
            return _wayPoints;
        }

        public void NextWayPoint()
        {
            if (_current < _wayPoints.Count - 1)
            {
                _current++;
            }
            else if (_isLoop)
            {
                _current = 0;
            }
        }

        public Vector2 GetNextWayPoint()
        {
            int next = _current;
            if (next < _wayPoints.Count - 1)
            {
                next++;
            }
            else if (_isLoop)
            {
                next = 0;
            }

            return _wayPoints[next];
        }

        public Vector2 CurrentWayPoint()
        {
            return _wayPoints[_current];
        }

        public bool Finished()
        {
            if (_isLoop)
            {
                return false;
            }

            return _current + 1 == _wayPoints.Count;
        }
    }
}